package controler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import model.beans.UsuarioBean;

import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.MessageResources;

import business.Usuario;

public class Validate {
	protected static UsuarioBean user_log_t = null;
	
	protected static ActionForward validateSession(ActionMapping mapping, HttpServletRequest request, MessageResources resources)throws Exception {
		ActionForward action_retVal = null;
		HttpSession session = request.getSession();
		user_log_t =(UsuarioBean)session.getAttribute("ses_usuario");
    	int int_validaSession = Usuario.validarSession(user_log_t);
    	if(int_validaSession==Usuario.SESSIONNOVALIDA){
    		action_retVal = mapping.findForward("session_invalid");
    	}
    	/*if(int_validaSession==Usuario.ACADEMIANOVALIDA){
    		request.setAttribute("req_msg", resources.getMessage("AcademyWelcome.Select") );
    		action_retVal = mapping.findForward("academy_invalid");
    	}*/
    	return action_retVal;
	}
	
	protected static ActionForward validateUser(ActionMapping mapping, HttpServletRequest request, MessageResources resources)throws Exception {
		ActionForward action_retVal = null;
		HttpSession session = request.getSession();
		user_log_t =(UsuarioBean)session.getAttribute("ses_usuario");
    	int int_validaSession = Usuario.validarSession(user_log_t);
    	if(int_validaSession==Usuario.SESSIONNOVALIDA){
    		action_retVal = mapping.findForward("session_invalid");
    	}
    	return action_retVal;
	}
}